package util

import (
	"crypto/md5"
	"encoding/hex"
	"fmt"
)

//取得MD5
func GetMD5(text string) string {
	data := []byte(text)
	md5Ctx := md5.New()
	md5Ctx.Write(data)
	cipherStr := md5Ctx.Sum(nil)
	//fmt.Println(cipherStr)
	return hex.EncodeToString(cipherStr)
}

//方式二
func GetMd5String2(b string) string {
	return fmt.Sprintf("%x", md5.Sum([]byte(b)))
}
